<?php

use yii\helpers\Url;
$web = Url::base();
$this->title = '扩展分类';
?>
<script type="text/javascript" src="<?= $web ?>/js/jquery.tooltips.js"></script>
<script type="application/javascript">
    //筛选
    function filter() {
        var institution_code = $("#institution").val();
        if (institution_code == null || institution_code == '') {
            institution_code = '0';
            alert('请选择机构');
            return;
        }
        var href = window.location.href;
        href = setUrlParam(href, 'inst', institution_code);
        var budget_year=$("#budget_year").val();
        if (budget_year == null || budget_year == '') {
            budget_year = '0';
            //alert('请选择预算年份');
            //return;
        }
        href = setUrlParam(href, 'budget_year', budget_year);
        window.location.href = href;
    }



    //打开新增修改页面
    function showBudgetEdit(data) {
        $("#WalfareBudgetEdit").html('');
       // $("#myModalShowLabelInst").html(data.institution_code);
        requestHtml('walfare-budget-edit-view', data, true, function (responseHtml) {
            $("#WalfareBudgetEdit").html(responseHtml);
            $("#myModalWalfareBudgetEdit").modal('show');
        });
    }
    //新增
    function addData() {

        var institution_code = $("#institution").val();
        var data = {};
        data.institution_code = institution_code;
        $("#myModalLabel").html("新增");
        showBudgetEdit(data);
    }

    //修改/查看详情
    function editData(id, institution_code) {
        var data = {};
        data.id = id;
        data.institution_code = institution_code;
        $("#myModalLabel").html("编辑/查看");
        showBudgetEdit(data);

    }
</script>
<!-- head filter-->
<div class="panel panel-default">
    <div class="panel-body">
        <div class="form-inline">
            <div class="btn-group">

                <button class="btn btn-primary" type="button" onclick="addData()"
                        data-toggle="modal"><i class="fa fa-plus"></i> 新增
                </button>

            </div>
            <div class="pull-right">
                <div class="form-group">
                    <label class="sr-only"  >机构</label>
                    <?= app\widgets\InstitutionHierarchyAutocompleteWidget::widget(['id' => 'institution', 'currentInstitutionCode' => $institution_code, 'defaultText' => '——选择机构——']) ?>
                </div>
                <div class="form-group">
                    <label class=""  >预算年度</label>
                    <select class="form-control popovers" style="width: 160px;" id="budget_year">
                        <option value="">--全部--</option>
                        <option value="2017">2017</option>
                        <option value="2018">2018</option>
                        <option value="2019">2019</option>
                        <option value="2020">2020</option>
                        <option value="2021">2021</option>
                        <option value="2022">2022</option>
                    </select>
                </div>

                <button type="button" class="btn btn-primary" onclick="filter()"><i class="fa fa-search"></i> 搜索
                </button>
            </div>
        </div>
    </div>
</div>
<!-- body table-->
<div class="panel panel-default" id="goodsList">
    <div class="panel-body">
        <div class="table-responsive">
            <table class="table table-bordered table-hover table-condensed">
                <thead class="nowrap">
                <tr>
                    <th style="width:20%">机构编码</th>
                    <th style="width:20%">部门</th>
                    <th style="width:15%">预算名称</th>
                    <th style="width:10%">预算年度</th>
                    <th style="width:10%">是否是月预算</th>
                    <th style="width:25%">操作</th>
                </tr>
                </thead>
                <tbody>

                </tbody>
            </table>
        </div>
    </div>
</div>

<!-- Modal ad Edit-->
<div class="modal fade" id="myModalWalfareBudgetEdit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                        aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel"></h4>
            </div>
            <div id="WalfareBudgetEdit" class="modal-body">
            </div>
            <div class="modal-footer">

                <button type="button" class="btn btn-primary" onclick="saveData()"><i class="fa fa-save"></i> 保存
                </button>
                <button type="button" class="btn btn-primary" data-dismiss="modal"><i class="fa fa-remove"></i> 取消
                </button>
            </div>
        </div>
    </div>
</div>